/* -*- c -*- */

%{
#include <stdio.h>
%}

%program "examples"
%usage   "[-dv] [-s str] [-i int] [-I uint] [-f float] [--size width height] arg ..."

%%

-d:
  help "Debug mode",
{ printf("debug mode\n"); }

-v:
  help "Verbose mode",
{ printf("verbose mode\n"); }

-s arg:
  help "String test",
{ printf("-s: %s (char *)\n", $arg); }

-i arg:
  help "Integer test",
  type int,
{ printf("-i: %ld (int)\n", $arg); }

-I arg:
  help "Unsigned integer test",
  type uint,
{ printf("-I: %ld (unsigned int)\n", $arg); }

-f arg:
  help "Float test",
  type float,
{ printf("-f: %f (double)\n", $arg); }

--size width height:
  help "Multiple arguments test",
  type int,
{ printf("--size: width=%ld, height=%ld\n", $width, $height); }

+ args ...:
{
  int i;
  printf("positional arguments: ");
  for (i = 0; i < $nvargs; i++) {
    printf("%s ", $args[i]);
  }
  printf("\n");
}

%%

int
main(int argc, char **argv)
{
  lg_parse(argc, argv);
  return 0;
}
